<!DOCTYPE html>
<html lang="ch" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <title>Category类型</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/lib/layui-v2.6.3/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
</head>

<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索Category</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="/categories/search" method="get">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">名称关键词</label>
                            <div class="layui-input-inline">
                                <input type="text" name="keyword" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"><i class="layui-icon"></i> 搜 索</button>
                        </div>

                        <div class="layui-inline">
                            <!--                            lay-submit lay-filter="data-search-btn"-->
                            <button type="submit" class="layui-btn layui-btn-primary"><i class="layui-icon"></i> 所有Category</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <!--数据的表格-->
        <fieldset class="table-categories-fieldset">
            <legend>Category信息</legend>
            <table class="layui-hide" id="TableId" lay-filter="currentTableFilter">
                <div></div>
                <form class="layui-form layui-form-pane">
                <table class="layui-table">
                    <tr>

                        <th>ID</th>
                        <th>Name</th>
                        <th>图片</th>
                        <th>操作</th>

                    </tr>
                    <tr th:if="${categoryList.size()} eq 0">
                        <td colspan="12">没有Category信息！！</td>
                    </tr>
                    <tr th:each="category: ${categoryList}">
                        <td>
                            <a class="underline" th:href="@{'categories/'+${category.catid}+'/products'}" target="_self" th:text="${category.catid}"></a>
                        </td>
                        <td th:text="${category.name}" />
                        <td>
                            <img th:src="@{'data:image/png;base64,'+${category.descn}}">
                            <!--请在这里注意图片接收-->
                        </td>
                        <td>
                            <button class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" >
                                <a th:href="@{'/categories/'+${category.catid}}">
                                    编辑
                                </a>
                            </button>
                            <button type="submit" class="layui-btn layui-btn-xs layui-btn-danger data-count-delete">
                                <a th:href="@{'/categories/delete/'+${category.catid}}">
                                    删除
                                </a>
                            </button>
                        </td>
                    </tr>
                </table>
                </form>

            </table>
        </fieldset>

        <fieldset class="table-search-fieldset">
            <legend>添加Category</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="/categories" method="post" enctype="multipart/form-data">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">ID</label>
                            <div class="layui-input-inline">
                                <input type="text" name="catid" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 150px">Name</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <!--    图片上传-->
                        <div class="layui-form-item">
                            <label class="layui-form-label required">图片</label>
                            <div class="layui-input-block">
                                <img src="/images/addImg.png" id="descnImg" height="90" width="160">
                                <input type="file" id="chooseImage" name="file">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"><i class="layui-icon"></i> 添 加 </button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
    </div>
</div>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"> </script>
<script src="../js/chooseImg.js" charset="utf-8"> </script>
</body>

</html>